package com.allen;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.ss.usermodel.Cell;

import com.allen.excelUtils.column.annotation.CellFormat;


public class DemoCellFormatter {

	@CellFormat(name="formateTime")
	public static Date formatStartTime(Cell cell) throws ParseException {
		Date date;
		if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC
				&& HSSFDateUtil.isCellDateFormatted(cell)) {
			date = cell.getDateCellValue();
		} else {
			DateFormat format = new SimpleDateFormat("yyyy-MM");
			date = format.parse(cell.getStringCellValue());
		}
		return date;
	}
	
	@CellFormat(name="formateOpertor")
	public static String formatOpertor(Cell cell) throws ParseException {
		return "admin";
	}
	
	
}
